//
//  ZZInFactoryViewModel.m
//  新项目
//
//  Created by liGordon on 17/3/23.
//  Copyright © 2017年 刘耀宗. All rights reserved.
//

#import "ZZInFactoryViewModel.h"

@implementation ZZInFactoryViewModel

+(instancetype)shareViewModel
{
    static id instance;
    static  dispatch_once_t once;
    dispatch_once(&once, ^{
        instance=[[self alloc] init];
    });
    return instance;
}

-(void)getCarInfoWithCompanyID:(NSString *)companyID andPageIndex:(NSString *)pageIndex andType:(NSString *)type andStartTime:(NSString *)startTime andEndTime:(NSString *)endTime andSuccess:(void (^)(NSDictionary *))success andFailer:(void (^)())failer
{
    NSMutableDictionary *strDic = [NSMutableDictionary dictionary];
    [strDic setKey:@"companyid" forValue:companyID];
    [strDic setKey:@"pageSize" forValue:@(upNum)];
    [strDic setKey:@"pageIndex" forValue:pageIndex];
    [strDic setKey:@"type" forValue:type];//1：预约 ：进厂，3结算
    [strDic setKey:@"startTime" forValue:startTime];
    [strDic setKey:@"endTime" forValue:endTime];
  
    NSString *jsonStr=[WHJSON jsonStringWithObject:strDic];
    
    NSMutableDictionary *dic=[NSMutableDictionary dictionary];
    [dic setKey:@"data" forValue:jsonStr];
    
    [YBHttpTool post:@"api/CmpCarInfo/CarInfo/GetCar" params:dic success:^(NSDictionary *obj) {
        DLog(@"=====%@",obj);
        if ([obj isKindOfClass:[NSNull class]] || obj==nil) {
            DLog(@"返回值为空");
            return ;
        }
        success(obj);
        
    } failure:^(NSError *error) {
        DLog(@"%@",error);
        failer();
    }];

}

@end
